package com.idbk.chargestation.bean;

import java.util.Arrays;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

/**
 * 充电点采集历史
 * @author liangzw,lupc
 *
 */
public class JsonHistory implements Parcelable {

	public final static String KEY = "JsonHistory";

	/**
	 * 照片上传的大小限制：500kb
	 */
	public final static long IMAGE_SIZI_LIMIT = 500 * 1024;

	/**
	 * 停车类型：地面
	 */
	public final static int PARKING_GROUND = 1;
	/**
	 * 停车类型：地下停车场
	 */
	public final static int PARKING_UNDERGROUND = 2;


	/**
	 * 充电方式：刷卡
	 */
	public final static int CHARGE_METHOD_CARD = 1;
	/**
	 * 充电方式：APP
	 */
	public final static int CHARGE_METHOD_APP = 2;
	/**
	 * 充电方式：刷卡+APP
	 */
	public final static int CHARGE_METHOD_CARD_AND_APP = 3;
	
	/**
	 * 审核状态：审核中
	 */
	public final static int CHECK_STATUS_IN = 0;
	/**
	 * 审核状态：审核失败
	 */
	public final static int CHECK_STATUS_FAILED = 1;
	/**
	 * 审核状态：审核成功
	 */
	public final static int CHECK_STATUS_SUCCESS = 2;
	
	/**
	 * 功率描述：1-7kw
	 */
	public final static int POWER_DESC_1_7_KW = 1;
	/**
	 * 功率描述：7-50kw
	 */
	public final static int POWER_DESC_7_50_KW = 2;
	/**
	 * 功率描述：>50kw
	 */
	public final static int POWER_DESC_ABOVE_50_KW = 3;
	
	/**
	 * 充电桩类型：直流
	 */
	public final static int CHARGE_MODEL_DC = 1;
	/**
	 * 充电桩类型：交流
	 */
	public final static int CHARGE_MODEL_AC = 2;
	
	@SerializedName("id")
	public int id;//充电点Id

	@SerializedName("pointName")
	public String name;

	@SerializedName("lat")
	public double lat;//纬度

	@SerializedName("lng")
	public double lng;//经度

	@SerializedName("provinceName")
	public String provinceName;//省名

	@SerializedName("cityName")
	public String cityName;//市名

	@SerializedName("countyName")
	public String countyName;//县名

	@SerializedName("address")
	public String address;//地址

	@SerializedName("isOpening")
	public boolean isOpening;//是否对外开放

	@SerializedName("parkingType")
	public int parkingType;//停车类型
	
	@SerializedName("parkingFee")
	public String parkingFee;

	@SerializedName("chargeMethod")
	public int chargeMethod;//充电方式

	@SerializedName("count4Slow")
	public int count4Slow;//数量
	
	@SerializedName("chargeModel_Slow")
	public int chargeModel_Slow;//类型
	
	@SerializedName("electricityPriceInfo_Slow")
	public String electricityPriceInfo_Slow;//费用描述
	
	@SerializedName("power_Slow")
	public int power_Slow;//功率描述
	
	@SerializedName("count4Fast")
	public int count4Fast;
	
	@SerializedName("chargeModel_Fast")
	public int chargeModel_Fast;
	
	@SerializedName("electricityPriceInfo_Fast")
	public String electricityPriceInfo_Fast;
	
	@SerializedName("power_Fast")
	public int power_Fast;
	
	@SerializedName("count4Super")
	public int count4Super;
	
	@SerializedName("chargeModel_Super")
	public int chargeModel_Super;
	
	@SerializedName("electricityPriceInfo_Super")
	public String electricityPriceInfo_Super;
	
	@SerializedName("power_Super")
	public int power_Super;
	
	@SerializedName("isEnable")
	public boolean isEnable;//是否可用

	@SerializedName("isFree")
	public boolean isFree;//是否免费

	@SerializedName("contactNum")
	public String contactNum;//联系电话

	@SerializedName("notes")
	public String notes;//充电点包含桩的类型及个数

	@SerializedName("operatorId")
	public int operatorId;//运营商

	@SerializedName("imageURLs")
	public List<String> imageURL;//费用描述

	@SerializedName("checkStatus")
	public int checkStatus;//审核状态

	@SerializedName("time")
	public String time;//时间
	
	/**
	 * 照片的个数，该个数仅仅用于判断内部的数据传递
	 */
	private int imageCount;
	
	public JsonHistory() {

	}

	public JsonHistory(Parcel in) {
		id = in.readInt();
		name = in.readString();
		lat = in.readDouble();
		lng = in.readDouble();
		
		provinceName = in.readString();
		cityName = in.readString();
		countyName = in.readString();
		address = in.readString();

		parkingType = in.readInt();
		parkingFee = in.readString();
		
		chargeMethod = in.readInt();
		
		count4Slow = in.readInt();
		chargeModel_Slow = in.readInt();
		electricityPriceInfo_Slow = in.readString(); 
		power_Slow = in.readInt();
		
		count4Fast = in.readInt();
		chargeModel_Fast = in.readInt();
		electricityPriceInfo_Fast = in.readString(); 
		power_Fast = in.readInt();
		
		count4Super = in.readInt();
		chargeModel_Super = in.readInt();
		electricityPriceInfo_Super = in.readString(); 
		power_Super = in.readInt();
		
		contactNum = in.readString();
		notes = in.readString();
		operatorId = in.readInt();
		
		boolean[] val = new boolean[3];
		in.readBooleanArray(val);
		isOpening = val[0];
		isEnable = val[1];
		isFree = val[2];
		
		imageCount = in.readInt();
		if(imageCount == 0){
			
		} else {
			String[] urls = new String[imageCount];
			in.readStringArray(urls);
			imageURL = Arrays.asList(urls);
		}

		checkStatus = in.readInt();
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(name);
		dest.writeDouble(lat);
		dest.writeDouble(lng);

		dest.writeString(provinceName);
		dest.writeString(cityName);
		dest.writeString(countyName);
		dest.writeString(address);

		dest.writeInt(parkingType);
		dest.writeString(parkingFee == null ? "0":parkingFee);
		
		dest.writeInt(chargeMethod);
		
		dest.writeInt(count4Slow);
		dest.writeInt(chargeModel_Slow);
		dest.writeString(electricityPriceInfo_Slow == null ? "":electricityPriceInfo_Slow);
		dest.writeInt(power_Slow);
		
		dest.writeInt(count4Fast);
		dest.writeInt(chargeModel_Fast);
		dest.writeString(electricityPriceInfo_Fast == null ? "":electricityPriceInfo_Fast);
		dest.writeInt(power_Fast);
		
		dest.writeInt(count4Super);
		dest.writeInt(chargeModel_Super);
		dest.writeString(electricityPriceInfo_Super == null ? "":electricityPriceInfo_Super);
		dest.writeInt(power_Super);
		
		dest.writeString(contactNum == null ? "":contactNum);
		dest.writeString(notes == null ? "":notes);
		dest.writeInt(operatorId);
				
		boolean[] val = new boolean[3];
		val[0] = isOpening;
		val[1] = isEnable;
		val[2] = isFree;
		dest.writeBooleanArray(val);
		
		if(imageURL == null || imageURL.size() < 1){
			imageCount = 0;
			dest.writeInt(imageCount);
		} else {
			imageCount = imageURL.size();
			dest.writeInt(imageCount);
			String[] urls = new String[imageCount];
			for (int i = 0; i < imageCount; i++) {
				urls[i] = imageURL.get(i);
			}
			dest.writeStringArray(urls);
		}

		dest.writeInt(checkStatus);
	}

	public final static Parcelable.Creator<JsonHistory> CREATOR = new Creator<JsonHistory>() {

		@Override
		public JsonHistory[] newArray(int size) {
			// TODO Auto-generated method stub
			return new JsonHistory[size];
		}

		@Override
		public JsonHistory createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new JsonHistory(source);
		}
	};

}
